package com.briup.mt.service.impl;
import com.briup.mt.bean.Dataset;
import com.briup.mt.bean.DatasetExample;
import com.briup.mt.dao.DatasetMapper;
import com.briup.mt.service.IDatasetService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import com.briup.mt.service.IDatasetService;
import java.util.List;
/**
 * @program: app03
 * @description: 用户信息实现类
 * @author: charles
 * @create: 2020-12-15 16:41
 **/
@Service
public class DatasetServiceImpl  implements IDatasetService {
    @Autowired
    private DatasetMapper datasetMapper;

    @Override
    public List<Dataset> query(String name) {
        // 模板
        DatasetExample example = new DatasetExample();
        if(!StringUtils.isEmpty(name)){
            example.createCriteria().andNameLike("name");
        }

        List<Dataset> list = datasetMapper.selectByExample(example);
        return list;
    }

    @Override
    public void saveOrUpdate(Dataset dataset) {
        // 如果userInfo中存在id属性，表示更新；否则保存
        if(dataset.getId() == null){
            datasetMapper.insert(dataset);
        } else {
            datasetMapper.updateByPrimaryKey(dataset);
        }
    }

    @Override
    public void deleteById(long id) {
        datasetMapper.deleteByPrimaryKey(id);
    }
}
